package com.andf.basic;

import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

public abstract class AndfSqlMapClientDao extends SqlSessionDaoSupport
{
	private TransactionStatus transactionStatus ;
	private DataSourceTransactionManager transactionManager ;
	
	public DataSourceTransactionManager getTransactionManager()
	{
		return transactionManager;
	}

	public void setTransactionManager(
			DataSourceTransactionManager transactionManager)
	{
		this.transactionManager = transactionManager;
	}
	
	public void beginTransaction()
	{
		transactionStatus = transactionManager.getTransaction(new DefaultTransactionDefinition());
	}
	
	public void commitTransaction()
	{
		transactionManager.commit( transactionStatus );
	}
	
	public void rollbackTransaction()
	{
		transactionManager.rollback( transactionStatus );
	}
}
